/**
 * erp订单开窗
 * @author miaoyl
 * @date 2019/03/14
 */
define(function () {

    var self,
        app = win.app,
        vueData = {
            tableData: [],
            count: 0,
            limit: 10,
            keyword: ''
        },
        table_where = {
            mlegal : '',
            TC004: '',
        },
        page = 1,
        cb
    ;

    app.newModule({
        init: function () {
            self = this;
            self._super({
                _tag: 'common_open_coptc_h'
            }, win);
        },
        queryDatas: function () {
            app.ajax({
                xurl: 'crm/gwai770/getCOPTCList',
                xdata: {
                    page: page,
                    limit: vueData.limit,
                    keyword: vueData.keyword,
                    mlegal : table_where.mlegal,
                    TC004: table_where.TC004
                },
                cb: function (result) {
                    if (result.ok) {
                        vueData.tableData.pushArray(result.data.data,true);
                        vueData.count = result.data.count;
                    }
                }
            });
        },

        _call:function (obj) {
            vueData.keyword = '';
            cb = obj.cb;
            table_where.mlegal = obj.mlegal;
            table_where.TC004 = obj.TC004;
            self.queryDatas();
        },

        _ready: function () {
            new Vue({
                el: '#common_open_coptc_h',
                data: vueData,
                methods: {
                    selectRow: function (inx, row) {
                        app.log(inx, row);
                        cb(row);
                        layer.close(layer.index);
                    },
                    handleSizeChange:function(val) {
                    },
                    handleCurrentChange:function(val) {
                        page = val;
                        self.queryDatas();
                    },
                    queryDatas:function () {
                        page = 1;
                        self.queryDatas();
                    }
                },
                created: function () {
                    self._setEleIsReady('common_open_coptc_h');
                }
            });
        },
        _lazy: function () {
            this._super();
        }
    });

});